package myMapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import myClass.like;

public interface likeMapper {
	
//	根据用户名获取所有该用户收藏的商品
	@Select("SELECT * FROM tb_like WHERE username=#{username}")
	public List<like> selectByUsername(@Param("username")String username);

//	根据用户名、商品id获取指定用户对指定产品的收藏情况
	@Select("SELECT * FROM tb_like WHERE username=#{username} AND like_id=#{like_id}")
	public List<like> selectLikeByUsername(@Param("username") String username,@Param("like_id") int like_id);
	
//	插入用户收藏商品
	@Insert("INSERT INTO tb_like VALUES(#{username},#{like_id})")
	public void insertLike(@Param("username") String username,@Param("like_id") int like_id);
	
//	用户取消收藏某商品
	@Delete("DELETE FROM tb_like WHERE username=#{username} AND like_id=#{like_id}")
	public void updateLike(@Param("username") String username,@Param("like_id") int like_id);
}
